<template>
	<view>
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="content">选择学生</block>
		</cu-custom>
		<a-fixed :height="44">
			<uni-search-bar placeholder="请输入姓名" :radius="100" @input="input"></uni-search-bar>
		</a-fixed>
		<a-scroll :request="get" ref="aScroll">
			<template #item="{row:x,index}">
				<a-list :value="x" @click="student(x)"></a-list>
			</template>
		</a-scroll>
	</view>
</template>

<script>
	export default {
		//上拉触底
		onReachBottom() {
			this.$refs.aScroll.lower();
		},
		//下拉刷新
		onPullDownRefresh() {
			this.$refs.aScroll.get(true).then(res => {
				uni.stopPullDownRefresh();
			});
		},
		data() {
			return {
				searchVal: ''
			}
		},
		methods: {
			input(res) {
				this.searchVal = res.value;
				this.$refs.aScroll.get(true);
			},
			get(parm = {}) {
				const data = new Array(15).fill({
					name: "喜来乐",
					phone: "八年级",
					// sonTitle: "八年级",
					// remark: "10号闸机",
					hideIcon: true,
				});
				console.log('请求：' + JSON.stringify({
					...parm,
					searchVal: this.searchVal
				}));
				return new Promise(r => {
					setTimeout(e => {
						r({
							total: 200,
							data
						})
					}, 1000);
				});
			},
			student(e){
				this.$BusEvent.$emit('selectStudents',e);
				history.go(-1);
			}
		}
	}
</script>
